<script type="text/javascript">
	function createTreeNode(nodeId, nodeText, parentId, isNext){
		var rootNode = document.getElementById(parentId);
		var prefix = null;
		
		if(isNext == "true"){
			prefix = document.createElement("p");
			prefix.id = nodeId;
		}else{
			prefix = document.createElement("dd");
			prefix.id = nodeId;
		}
		
		var v = document.createElement("a");
		//v.innerHTML = "&nbsp;&nbsp;&nbsp;" + nodeText;
		v.innerHTML = nodeText;
		v.href = "${var_contextpath}/category.xhtml?group="+nodeId+"";
		
		prefix.appendChild(v);
		rootNode.appendChild(prefix);
		
	}
</script>

[#-- 创建分类树子节点的自定义宏，参数：par_datalist 分类数据列表，par_parentid 父级分类ID。--]
[#macro ecs_grouptreechild par_datalist par_parentid par_isNext]
	[#list par_datalist as data]
		[#if data.bggParent == par_parentid]
			<script type="text/javascript">
				createTreeNode("${data.bggId}", "${data.bggName}", "${data.bggParent}", "${par_isNext}");
			</script>
			[@ecs_grouptreechild par_datalist = par_datalist par_parentid = data.bggId par_isNext = "true"/]
		[/#if]
	[/#list]
[/#macro]

[#-- 创建分类树根节点的自定义宏，参数：par_datalist 分类数据列表。--]
[#macro ecs_grouptreeroot par_datalist]
	<div class="box_1">
		<div id="category_tree">
		[#list par_datalist as data]
			[#if data.bggParent == "0"]
				<dl id="${data.bggId}">
					<dt><a href="${var_contextpath}/category.xhtml?group=${data.bggId}">${data.bggName}</a></dt>
				</dl>
				[@ecs_grouptreechild par_datalist = par_datalist par_parentid = data.bggId par_isNext = "false"/]
			[/#if]
		[/#list]
		</div>
	</div>	
[/#macro]

[#-- 创建搜索框Option生成 --]
[#-- 创建分类树子节点的自定义宏，参数：par_datalist 分类数据列表，par_parentid 父级分类ID。--]
[#macro ecs_optiontreechild par_datalist par_parentid]
	[#list par_datalist as data]
		[#if data.bggParent == par_parentid]
			<option value="${data.bggId}">
				&nbsp;&nbsp;&nbsp;&nbsp;${data.bggName}
			</option>
			[@ecs_optiontreechild par_datalist = par_datalist par_parentid = data.bggId/]
		[/#if]
	[/#list]
[/#macro]

[#-- 创建分类树根节点的自定义宏，参数：par_datalist 分类数据列表。--]
[#macro ecs_optiontreeroot par_datalist]
	[#list par_datalist as data]
		[#if data.bggParent == "0"]
			<option value="${data.bggId}">
				${data.bggName}
			</option>
			[@ecs_optiontreechild par_datalist = par_datalist par_parentid = data.bggId/]
		[/#if]
	[/#list]
[/#macro]
